import 'dart:math';

import 'package:flutter/material.dart';
import 'package:waterfall_flow/waterfall_flow.dart';

class DetailPage extends StatefulWidget{
  const DetailPage({Key? key}) : super(key: key);


  @override
  DetailState createState() => DetailState();
}

class DetailState extends State<DetailPage>{
  final List _list = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17];


  @override
  Widget build(BuildContext context){
    return Scaffold(
      body: WaterfallFlow.builder(
          padding: const EdgeInsets.all(5.0),
        gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount(
          crossAxisCount: 2,
          crossAxisSpacing: 5.0,
          mainAxisSpacing: 5.0,
          lastChildLayoutTypeBuilder: (index)=>index == _list.length?LastChildLayoutType.foot:LastChildLayoutType.none
        ),
        itemCount: _list.length,
        itemBuilder: (BuildContext context, int index) {
          return Container(
            width: 40,
            height: 80,
            decoration: BoxDecoration(
              color: Colors.primaries[index]
            ),
            child: Center(
              child: Text(_list[index].toString(),style: const TextStyle(color: Colors.white),),
            ),
          );
        },
      ),
    );
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  randomNum(){
    var data = Random().nextInt(100);

  }

}